package org.hepeng.hope.dao

import org.hepeng.hope.CornerstoneApplicationTests
import org.hepeng.hope.entity.Account
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ActiveProfiles
import kotlin.test.assertEquals


@ActiveProfiles(profiles = ["dev"])
internal class AccountDAOTest : CornerstoneApplicationTests() {


    @Autowired lateinit var dao: AccountDAO

    @Test fun insertTest() {
        val a = Account("xiaohua", "xiaohua@gmail.com").apply {
            createTime = System.currentTimeMillis()
            deleteFlag = false
        }
        val saved = dao.save(a)
    }

    @Test fun getOneTest() {
        var a = dao.getOne(1)
        assertEquals(2 , a.roles.size)

    }

    @Test fun findByIdTest() {
        val option = dao.findById(1)
        val r = option.get()
        println(r)
        assertEquals(2 , r.roles.size)

    }

    @Test fun findAllByIdTest() {

        var list = dao.findAllById(listOf(1))
        println(list)

    }
}